#pragma once

#include "Connection.h"

enum operation{del, update, mov, nop};
struct serverData{std::string hash, dir, file; enum operation op;};
struct directory{std::string dir; enum operation op;};

class Updater
{
public:
	Updater();
	~Updater(void);
	int compareVersion(){return localVersion-currentVersion;}
	int loadVersion();
	int loadChangeSet();
	int run();

private:
	std::list<struct serverData> files, s_data;
	std::list<struct directory> directories;
	char dir[MAX_PATH], *changeSet, root[128];
	u_int localVersion, currentVersion;
	Connection c;

	int listFiles(char *subdir=0, char *dir=0, char *root="");
	char* generateHash(char*);
	int calculateHashes();
	int update();
	void parseServerData(char*);
	void compareFiles();
};

